<template>
  <div class="boy">
      <h1>boy{{toy}}</h1>
      <button @click="sendToMei">哥哥给妹妹蛋糕</button>
  </div>
</template>

<script>
export default {
    name:"boy",
    data(){
        return{
            toy:"",
            cake:"蛋糕"
        }
    },
    mounted(){
        this.eventBus.$on("send-toy",(toy)=>{
            console.log('收到妹妹给的:',toy)
            this.toy =toy
        })
    },
    methods:{
        sendToMei(){
            this.eventBus.$emit("send-cake",this.cake)
        }
    }
}
</script>

<style scoped>
.boy{
    width: 200px;
    height: 200px;
    border: 1px solid pink;
}
</style>>

